/**
 * MobileWorship
 * Copyright (C) 2010 Petra Barus
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.petrabarus.mobileworship.ui;

import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.Border;
import javax.microedition.midlet.MIDlet;

/**
 *
 * @author Petra Barus
 */
public class MainForm extends Form implements ActionListener {

    private MIDlet midlet;
    private TextArea lyricText;
    private Container headerContainer;
    //
    private Command exitCommand;
    private Command test2Command;
    private Command gotoCommand;
    private Command aboutCommand;

    /**
     * 
     * @param midlet
     */
    public MainForm(MIDlet midlet) {
        super("Mobile Worship");
        this.midlet = midlet;
        init();
    }

    /**
     * Initialize components
     */
    public void init() {
        setLayout(new BorderLayout());
        lyricText = new TextArea();
        lyricText.setText("test");
        lyricText.getStyle().setMargin(0, 0, 0, 0);
        lyricText.getStyle().setPadding(5, 5, 5, 5);
        lyricText.getStyle().setBgTransparency(0);
        lyricText.getStyle().setBorder(Border.createEmpty());
        lyricText.setEditable(false);
        lyricText.setFocusable(false);
        lyricText.setGrowByContent(true);
        //
        headerContainer = new Container();
        headerContainer.addComponent(new Label("Kidung Jemaat 1. Title"));
        //
        addComponent(BorderLayout.CENTER, lyricText);
        addComponent(BorderLayout.NORTH, headerContainer);
        //
        exitCommand = new Command("Exit");
        //
        test2Command = new Command("Test2");

        gotoCommand = new Command("Go To");
        aboutCommand = new Command("About");

        addCommand(exitCommand);
        addCommand(aboutCommand);
        addCommand(test2Command);
        addCommand(gotoCommand);
        //
        addCommandListener(this);
    }

    /**
     * Handle command
     * @param ae
     */
    public void actionPerformed(ActionEvent ae) {
        Command c = ae.getCommand();
        if (c == exitCommand) {
            midlet.notifyDestroyed();
        } else if (c == gotoCommand) {
        } else if (c == aboutCommand) {
        }
    }
}
